package com.zzgele.qmzb.api.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.zzgele.qmzb.api.core.AbstractService;
import com.zzgele.qmzb.api.dao.UserLoggerMapper;
import com.zzgele.qmzb.api.model.UserLog;
import com.zzgele.qmzb.api.service.UserLogService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import tk.mybatis.mapper.entity.Condition;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by Martin on 2017/08/04.
 */
@Service(interfaceClass = UserLogService.class,proxy="jdk")
@Component
@Transactional
public class UserLogServiceImpl extends AbstractService<UserLog> implements UserLogService {
    @Resource
    private UserLoggerMapper userLoggerMapper;

    @Resource
    JedisPool jedisPool;

    public long getTime(String login_uid) {
        Jedis client = jedisPool.getResource();
        long times=client.hincrBy(String.valueOf(login_uid),"share",1);
        client.close();
        return times;
    }

    @Override
    public List<UserLog> findByConditions(Long login_uid, String uuid) {
        Condition condition=new Condition(UserLog.class);
        condition.createCriteria().andCondition("uid=" + login_uid + " AND uuid=" + uuid);
        return userLoggerMapper.selectByCondition(condition);
    }

}
